﻿using System;
using System.IO;
using System.Net;
using System.Text;
using Newtonsoft.Json.Linq;
using YookingBizWQW.Class.Credit.pub;
using YookingBizWQW.Class.Public;
using YookingFileIO.Class;
using YookingInterfaceAli.Class.OpenApi;
using YookingSvrDBCall.Class.DBLogic;
using YookingSvrDBCall.Class.DBPub;

namespace YookingBizWQW.Class.Credit.mp
{
    public class clsCrCardData
    {
        //注释：王庆文 2020年03月14日===================================================
        //查找并显示银行代码字典信息
        public string GetBankCodeInfo(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strKeyWord = "test"; //银行名称关键词

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 1)
            {
                strKeyWord = strArray[0];
            }

            #endregion

            #region 生成查询记录的SQL语句

            clsDBSpace mySpace = new clsDBSpace(); //表空间名
            string strSysSapace = mySpace.GetDBSpaceName("Sys");
            string strDataSapace = mySpace.GetDBSpaceName("Data");

            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine(" SELECT ");
            sbQuerySQL.AppendLine("     T.DICTCODE, ");
            sbQuerySQL.AppendLine("     T.DICTMEMO, ");
            sbQuerySQL.AppendLine("     T.DICTSPELL, ");
            sbQuerySQL.AppendLine("     B.IMAGEENTITY ");
            sbQuerySQL.AppendLine(" FROM DICT_XYK_BANKCODE T ");
            sbQuerySQL.AppendLine(" LEFT JOIN " + strSysSapace + ".DB_TABLEDEFINE A ON UPPER(A.TABLENAME) = 'DICT_XYK_BANKCODE' ");
            sbQuerySQL.AppendLine(" LEFT JOIN " + strDataSapace + ".MDA_PUBLICIMAGE B ON B.MAINTABLERECORDID = T.SYS_RECORDID ");
            sbQuerySQL.AppendLine(" AND (B.SPECIALRELATENUMBER = T.DICTCODE OR B.SPECIALRELATENUMBER = T.DICTSPELL) ");
            sbQuerySQL.AppendLine(" AND( ");
            sbQuerySQL.AppendLine("     UPPER(B.MAINTABLEDEFINEID) = 'DICT_XYK_BANKCODE' ");
            sbQuerySQL.AppendLine("     OR B.MAINTABLEDEFINEID = A.TABLEID ");
            sbQuerySQL.AppendLine(" ) ");
            sbQuerySQL.AppendLine(" WHERE ");
            sbQuerySQL.AppendLine("     " + clsSQLSyntax.IsNullSQL("Dict", "T.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" AND " + clsSQLSyntax.IsNullSQL("Sys", "A.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" AND " + clsSQLSyntax.IsNullSQL("Data", "B.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" AND T.DICTMEMO LIKE '%" + strKeyWord + "%' ");
            sbQuerySQL.AppendLine(" AND " + clsSQLSyntax.RowRange("Dict", 0, 50));

            #endregion

            //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "wqw.txt", sbQuerySQL.ToString());

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            strRtData = myDB.YookingExecuteJson("Dict", sbQuerySQL.ToString());

            return strRtData; //数据库查询结果
        }

        //注释：王庆文 2020年03月14日================================================================
        //调用阿里支付宝的接口，根据银行卡号，查找银行代码字典信息
        //返回的数据格式如下：
        //{"cardType":"CC","bank":"CITIC","key":"1578107599053-3908-11.190.194.56-862233248","messages":[],"validated":true,"stat":"ok"}
        public string GetBankInfo_FromAli(string strB64RequestData)
        {
            string strRtData = "{\"messages\":\"yooking null\"}";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strCardNumber = "000"; //银行卡号

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 1)
            {
                strCardNumber = strArray[0];
            }

            #endregion

            clsBankCard myBC = new clsBankCard(); //从阿里接口获取银行信息
            strRtData = myBC.GetBankCode_FromAli(strCardNumber);

            //只有阿里接口返回了正确的结果之后，才会进一步的分析和处理
            if (!strRtData.Contains("yooking null"))
            {
                //也有可能接口查询出错
                try
                {
                    JObject objJson = JObject.Parse(strRtData);  //json数组文本转成对象
                    string strBankCode = objJson["bank"].ToString(); //银行代码

                    //根据银行代码，翻译出银行的汉字名称
                    YookingDBNormal.Class.clsShare myKit = new YookingDBNormal.Class.clsShare();
                    string strBankName = myKit.GetNewColValue("Dict", "DICT_XYK_BANKCODE", "DICTCODE", strBankCode, "DICTMEMO");

                    string strB64ImgData = myBC.GetBankLogo_FromAli(strBankCode); //调用阿里接口，将银行代码转成logo图片

                    strRtData = strRtData.Replace("}", ",\"bankname\":\"" + strBankName + "\"}"); //返回结果中加入银行名称
                    strRtData = strRtData.Replace("}", ",\"banklogo\":\"" + strB64ImgData + "\"}"); //返回结果中加入银行LOGO

                }
                catch { }
            }

            return "[" + strRtData + "]"; //阿里接口返回的银行代码查询结果
        }

        //注释：王庆文 2020年05月07日================================================================
        //银行卡实名认证-银行卡三要素（详情版）
        //调用阿里云API，检查银行卡号、身份证号、持卡人姓名三者是否一致
        public string GetBank3CheckInfo(string strB64RequestData)
        {
            string strRtData = "{\"result\":\"yooking null\"}";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strBankCardNo = "000000"; //银行卡号
            string strIDCardNumber = "0000"; //持卡人身份证号
            string strPersonName = "aaaaaa"; //持卡人真实姓名

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 3)
            {
                strBankCardNo = strArray[0];
                strIDCardNumber = strArray[1];
                strPersonName = strArray[2];
            }

            #endregion

            clsBank3Check myCheck = new clsBank3Check(); //调用阿里接口，请求银行卡三要素检查
            strRtData = myCheck.GetBank3CheckInfo(strBankCardNo, strIDCardNumber, strPersonName);

            //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "wqw.txt", strRtData, false);

            return "[" + strRtData + "]"; //阿里接口返回的银行代码查询结果
        }

        //注释：王庆文 2020年03月14日===================================================
        //根据指定的条件查询会员本人的银行卡信息
        public string GetBankCardInfo(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strUnitCode = "CHN000"; //平台编码
            string strPersonCode = "0000"; //会员ID
            string strCondition = "1=1";   //附加查询条件

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 3)
            {
                strUnitCode = strArray[0];
                strPersonCode = strArray[1];
                strCondition = strArray[2];
            }

            #endregion

            #region 生成查询记录的SQL语句

            clsDBSpace mySpace = new clsDBSpace(); //表空间名
            string strSysSapace = mySpace.GetDBSpaceName("Sys");
            string strDictSapace = mySpace.GetDBSpaceName("Dict");

            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine(" SELECT ");
            sbQuerySQL.AppendLine(" 	T.UNITCODE, ");
            sbQuerySQL.AppendLine(" 	T.PERSONCODE, ");
            sbQuerySQL.AppendLine(" 	T.CARDTYPE, ");
            sbQuerySQL.AppendLine(" 	T.BANKCODE, ");
            sbQuerySQL.AppendLine(" 	A.DICTMEMO AS BANKNAME, ");
            sbQuerySQL.AppendLine(" 	T.CARDNO, ");
            sbQuerySQL.AppendLine(" 	T.EXPIREDDATE, ");
            sbQuerySQL.AppendLine(" 	T.CVV2, ");
            sbQuerySQL.AppendLine(" 	T.MOBILEPHONE, ");
            sbQuerySQL.AppendLine(" 	T.REGTIME, ");
            sbQuerySQL.AppendLine(" 	T.POSBINDSTATUS, ");
            sbQuerySQL.AppendLine(" 	T.POSBINDTIME, ");
            sbQuerySQL.AppendLine(" 	T.POSBINDSMS, ");
            sbQuerySQL.AppendLine(" 	T.ATMBINDSTATUS, ");
            sbQuerySQL.AppendLine(" 	T.ATMBINDTIME, ");
            sbQuerySQL.AppendLine(" 	T.ATMBINDSMS, ");
            sbQuerySQL.AppendLine(" 	T.HBEIBINDSTATUS, ");
            sbQuerySQL.AppendLine(" 	T.HBEIBINDTIME, ");
            sbQuerySQL.AppendLine(" 	T.HBEIBINDSMS, ");
            sbQuerySQL.AppendLine(" 	T.OTHERMEMO, ");
            sbQuerySQL.AppendLine(" 	T.SYS_RECORDID, ");
            sbQuerySQL.AppendLine(" 	C.IMAGEENTITY AS BANKLOGO");
            sbQuerySQL.AppendLine(" FROM ");
            sbQuerySQL.AppendLine(" 	XYK_BANKCARD T ");
            sbQuerySQL.AppendLine(" LEFT JOIN " + strDictSapace + ".dict_xyk_bankcode A ON A.DictCode=T.BankCode ");
            sbQuerySQL.AppendLine(" LEFT JOIN " + strSysSapace + ".DB_TABLEDEFINE B ON upper(B.TABLENAME)='DICT_XYK_BANKCODE' ");
            sbQuerySQL.AppendLine(" LEFT JOIN mda_publicimage C ON ( ");
            sbQuerySQL.AppendLine(" 	upper(C.MAINTABLEDEFINEID) = 'DICT_XYK_BANKCODE' ");
            sbQuerySQL.AppendLine(" 	OR C.MAINTABLEDEFINEID = B.TABLEID ");
            sbQuerySQL.AppendLine(" ) ");
            sbQuerySQL.AppendLine(" AND C.MAINTABLERECORDID = A.Sys_RecordID ");
            sbQuerySQL.AppendLine(" AND ( ");
            sbQuerySQL.AppendLine(" 	C.SPECIALRELATENUMBER = A.DictCode ");
            sbQuerySQL.AppendLine(" 	OR C.SPECIALRELATENUMBER = A.DictSpell ");
            sbQuerySQL.AppendLine(" ) ");
            sbQuerySQL.AppendLine(" WHERE " + clsSQLSyntax.IsNullSQL("Data", "T.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" AND	" + clsSQLSyntax.IsNullSQL("Dict", "A.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" AND	" + clsSQLSyntax.IsNullSQL("Sys", "B.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" AND	" + clsSQLSyntax.IsNullSQL("Data", "C.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" AND T.UNITCODE = '" + strUnitCode + "' ");
            sbQuerySQL.AppendLine(" AND T.PERSONCODE = '" + strPersonCode + "' ");
            sbQuerySQL.AppendLine(" AND " + strCondition);

            #endregion

            //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "wqw.txt", sbQuerySQL.ToString());

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            strRtData = myDB.YookingExecuteJson("Data", sbQuerySQL.ToString());

            return strRtData; //数据库查询结果
        }

        //注释：王庆文 2020年03月18日===================================================
        //统计指定会员累计信用卡还款总额
        public string LoadAllRepayAmount(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strUnitCode = "CHN000"; //平台编码
            string strMID = "0000"; //会员ID

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 2)
            {
                strUnitCode = strArray[0];
                strMID = strArray[1];
            }

            #endregion

            #region 生成查询记录的SQL语句

            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine(" SELECT ");
            sbQuerySQL.AppendLine(" 	ROUND(IFNULL(SUM(T.TRADEAMOUNT), '0'),2) AS ALLREPLAYAMOUNT ");
            sbQuerySQL.AppendLine(" FROM XYK_TRADEORDER T ");
            sbQuerySQL.AppendLine(" LEFT JOIN XYK_REPAYPLAN A ON T.PLANID = A.PLANID ");
            sbQuerySQL.AppendLine(" WHERE " + clsSQLSyntax.IsNullSQL("Data", "T.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine("   AND " + clsSQLSyntax.IsNullSQL("Data", "A.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine("   AND A.UNITCODE = '" + strUnitCode + "' ");
            sbQuerySQL.AppendLine("   AND A.PERSONCODE = '" + strMID + "' ");
            sbQuerySQL.AppendLine("   AND (T.TRADETYPE = 'POS01' OR T.TRADETYPE = 'ATM01' OR T.TRADETYPE = 'HBEI01') ");
            sbQuerySQL.AppendLine("   AND (T.REALTRADESTATE = '00' OR T.REALSETTSTATE = '00') ");

            #endregion

            //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "wqw_clsCrCardData_LoadAllRepayAmount.txt", sbQuerySQL.ToString(),false);

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            strRtData = myDB.YookingExecuteJson("Data", sbQuerySQL.ToString());

            return strRtData; //数据库查询结果
        }

        //注释：王庆文 2020年03月18日===================================================
        //获取当前用户名下的全部信用卡登记基础信息
        public string LoadCreditCardInfo(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strUnitCode = "CHN000"; //平台编码
            string strMID = "0000"; //会员ID

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 2)
            {
                strUnitCode = strArray[0];
                strMID = strArray[1];
            }

            #endregion

            #region 生成查询记录的SQL语句

            clsDBSpace mySpace = new clsDBSpace(); //表空间名
            string strSysSapace = mySpace.GetDBSpaceName("Sys");
            string strDictSapace = mySpace.GetDBSpaceName("Dict");

            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine(" select ");
            sbQuerySQL.AppendLine("     T.UNITCODE, ");
            sbQuerySQL.AppendLine(" 	T.PERSONCODE, ");
            sbQuerySQL.AppendLine(" 	T.CARDTYPE, ");
            sbQuerySQL.AppendLine(" 	T.BANKCODE, ");
            sbQuerySQL.AppendLine("     A.DICTMEMO AS BANKNAME, ");
            sbQuerySQL.AppendLine("     C.IMAGEENTITY AS BANKLOGO, ");
            sbQuerySQL.AppendLine(" 	T.CARDNO, ");
            sbQuerySQL.AppendLine(" 	T.EXPIREDDATE, ");
            sbQuerySQL.AppendLine(" 	T.CVV2, ");
            sbQuerySQL.AppendLine(" 	T.MOBILEPHONE, ");
            sbQuerySQL.AppendLine(" 	T.REGTIME, ");
            sbQuerySQL.AppendLine(" 	T.POSBINDSTATUS, ");
            sbQuerySQL.AppendLine(" 	T.POSBINDTIME, ");
            sbQuerySQL.AppendLine(" 	T.POSBINDSMS, ");
            sbQuerySQL.AppendLine(" 	T.ATMBINDSTATUS, ");
            sbQuerySQL.AppendLine(" 	T.ATMBINDTIME, ");
            sbQuerySQL.AppendLine(" 	T.ATMBINDSMS, ");
            sbQuerySQL.AppendLine(" 	T.HBEIBINDSTATUS, ");
            sbQuerySQL.AppendLine(" 	T.HBEIBINDTIME, ");
            sbQuerySQL.AppendLine(" 	T.HBEIBINDSMS, ");
            sbQuerySQL.AppendLine(" 	T.OTHERMEMO ");
            sbQuerySQL.AppendLine(" from XYK_BankCard t ");
            sbQuerySQL.AppendLine("   LEFT JOIN " + strDictSapace + ".dict_xyk_bankcode a on a.DictCode=t.BankCode ");
            sbQuerySQL.AppendLine("   LEFT JOIN " + strSysSapace + ".DB_TableDefine b ON upper(b.TableName)='DICT_XYK_BANKCODE' ");
            sbQuerySQL.AppendLine("   LEFT JOIN Mda_PublicImage c ON (upper(c.MainTableDefineID)='DICT_XYK_BANKCODE' OR c.MainTableDefineID = b.TableID) AND c.MainTableRecordID=a.Sys_RecordID AND (c.SpecialRelateNumber=a.DictCode or c.SpecialRelateNumber=a.DictSpell) ");
            sbQuerySQL.AppendLine(" where " + clsSQLSyntax.IsNullSQL("Data", "t.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine("   AND " + clsSQLSyntax.IsNullSQL("Sys", "b.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine("   AND " + clsSQLSyntax.IsNullSQL("Data", "c.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine("   AND t.UnitCode='" + strUnitCode + "' ");
            sbQuerySQL.AppendLine("   AND t.PersonCode='" + strMID + "' ");
            sbQuerySQL.AppendLine("   AND t.CardType='01' ");

            #endregion

            //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "wqw.txt", sbQuerySQL.ToString());

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            strRtData = myDB.YookingExecuteJson("Data", sbQuerySQL.ToString());

            return strRtData; //数据库查询结果
        }

        //注释：王庆文 2020年05月13日=======================================================
        //判断用户的同一张信用卡是否已经存在计划交易时间冲突的还款计划。
        public string CheckHistoryRepayPlan(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strUnitCode = "CHN0000000"; //平台编码
            string strPersonCode = "00000000"; //用户人员编码
            string strBankCardNo = "AFDEQD/="; //信用卡密文卡号
            string strNewPlanStartTime = "00"; //新计划的开始时间

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 4)
            {
                strUnitCode = strArray[0];
                strPersonCode = strArray[1];
                strBankCardNo = strArray[2];
                strNewPlanStartTime = strArray[3];
            }

            #endregion

            #region 生成查询记录的SQL语句

            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine(" SELECT ");
            sbQuerySQL.AppendLine("   MAX(PLANDATEEND) AS OLDPLANDATEEND ");
            sbQuerySQL.AppendLine(" FROM XYK_REPAYPLAN T ");
            sbQuerySQL.AppendLine("   WHERE " + clsSQLSyntax.IsNullSQL("Data", "T.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine("    AND T.UNITCODE = '" + strUnitCode + "' ");
            sbQuerySQL.AppendLine("    AND T.PERSONCODE = '" + strPersonCode + "' ");
            sbQuerySQL.AppendLine("    AND T.BANKCARDNO = '" + strBankCardNo + "' ");
            sbQuerySQL.AppendLine("    AND T.PLANDATEEND >= '" + strNewPlanStartTime + "' ");

            #endregion

            //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "wqw.txt", sbQuerySQL.ToString(), false);

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            strRtData = myDB.YookingExecuteJson("Data", sbQuerySQL.ToString());

            return strRtData; //数据库查询结果
        }

        //注释：王庆文 2020年03月19日=====================================================
        //加载并显示指定卡号的信用的最后一次还款计划信息
        public string LoadLastRepayPlanInfo(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strUnitCode = "CHN000"; //平台编码
            string strCardNo = "00000000"; //信用卡卡号

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 2)
            {
                strUnitCode = strArray[0];
                strCardNo = strArray[1];
            }

            #endregion

            #region 生成查询记录的SQL语句

            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine(" SELECT ");
            sbQuerySQL.AppendLine(" 	UNITCODE, ");
            sbQuerySQL.AppendLine(" 	PLANID, ");
            sbQuerySQL.AppendLine(" 	PLANTYPE, ");
            sbQuerySQL.AppendLine(" 	PLANTIME, ");
            sbQuerySQL.AppendLine(" 	YMONTH, ");
            sbQuerySQL.AppendLine(" 	BANKCARDNO, ");
            sbQuerySQL.AppendLine(" 	PLANAMOUNT, ");
            sbQuerySQL.AppendLine(" 	CARDBALANCE, ");
            sbQuerySQL.AppendLine(" 	PLANDATEBEGIN, ");
            sbQuerySQL.AppendLine(" 	PLANDATEEND, ");
            sbQuerySQL.AppendLine(" 	PAYCITY, ");
            sbQuerySQL.AppendLine(" 	PLANSTATE, ");
            sbQuerySQL.AppendLine(" 	MEMBERLEVEL, ");
            sbQuerySQL.AppendLine(" 	OTHERMEMO ");
            sbQuerySQL.AppendLine(" FROM ");
            sbQuerySQL.AppendLine(" 	( ");
            sbQuerySQL.AppendLine(" 		SELECT ROW_NUMBER () OVER (ORDER BY PLANTIME DESC) RN,A.* ");
            sbQuerySQL.AppendLine(" 		FROM ");
            sbQuerySQL.AppendLine(" 			( ");
            sbQuerySQL.AppendLine(" 				SELECT DISTINCT ");
            sbQuerySQL.AppendLine(" 					T.UNITCODE, ");
            sbQuerySQL.AppendLine(" 					T.PLANID, ");
            sbQuerySQL.AppendLine(" 					T.PLANTYPE, ");
            sbQuerySQL.AppendLine(" 					T.PLANTIME, ");
            sbQuerySQL.AppendLine(" 					DATE_FORMAT(T.PLANTIME, '%Y-%m') AS YMONTH, ");
            sbQuerySQL.AppendLine(" 					T.BANKCARDNO, ");
            sbQuerySQL.AppendLine(" 					T.PLANAMOUNT, ");
            sbQuerySQL.AppendLine(" 	                T.CARDBALANCE, ");
            sbQuerySQL.AppendLine(" 					T.PLANDATEBEGIN, ");
            sbQuerySQL.AppendLine(" 					T.PLANDATEEND, ");
            sbQuerySQL.AppendLine(" 					T.PAYCITY, ");
            sbQuerySQL.AppendLine(" 					T.PLANSTATE, ");
            sbQuerySQL.AppendLine(" 					T.MEMBERLEVEL, ");
            sbQuerySQL.AppendLine(" 					T.OTHERMEMO ");
            sbQuerySQL.AppendLine(" 				FROM XYK_REPAYPLAN T ");
            sbQuerySQL.AppendLine(" 				WHERE " + clsSQLSyntax.IsNullSQL("Data", "T.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" 				AND T.UNITCODE = '" + strUnitCode + "' ");
            sbQuerySQL.AppendLine(" 				AND T.BANKCARDNO = '" + strCardNo + "' ");
            sbQuerySQL.AppendLine(" 			) A ");
            sbQuerySQL.AppendLine(" 	) S ");
            sbQuerySQL.AppendLine(" WHERE S.RN = '1' ");

            #endregion

            //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "wqw_clsCrCardData_LoadLastRepayPlanInfo.txt", sbQuerySQL.ToString());

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            strRtData = myDB.YookingExecuteJson("Data", sbQuerySQL.ToString());

            return strRtData; //数据库查询结果
        }

        //注释：王庆文 2020年03月19日=========================================================
        //查询还款计划数据库，获取主表XYK_RepayPlan和子表XYK_TradeOrder的刷卡及还款记录
        public string GetOlapRepayPlanResult(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strUnitCode = "CHN0000"; //平台编码
            string strPersonCode = "00000"; //人员编码
            string strSQLCondition = "1=1"; //附加查询条件

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 3)
            {
                strUnitCode = strArray[0];
                strPersonCode = strArray[1];
                strSQLCondition = strArray[2];
            }

            #endregion

            #region 生成查询记录的SQL语句

            clsDBSpace mySpace = new clsDBSpace(); //表空间名
            string strSysSapace = mySpace.GetDBSpaceName("Sys");
            string strDictSapace = mySpace.GetDBSpaceName("Dict");

            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine(" SELECT DISTINCT ");
            sbQuerySQL.AppendLine("  	T.SYS_RECORDID, ");
            sbQuerySQL.AppendLine("  	T.UNITCODE, ");
            sbQuerySQL.AppendLine("  	T.PERSONCODE, ");
            sbQuerySQL.AppendLine("  	T.PLANID, ");
            sbQuerySQL.AppendLine("  	T.PLANTYPE, ");
            sbQuerySQL.AppendLine("  	H.DICTMEMO, ");
            sbQuerySQL.AppendLine("  	T.PLANTIME, ");
            sbQuerySQL.AppendLine("  	DATE_FORMAT(T.PLANTIME,'%Y.%m') AS YMONTH, ");
            sbQuerySQL.AppendLine("  	T.BANKCARDNO, ");
            sbQuerySQL.AppendLine("  	T.PLANAMOUNT, ");
            sbQuerySQL.AppendLine(" 	T.CARDBALANCE, ");
            sbQuerySQL.AppendLine("  	T.PLANDATEBEGIN, ");
            sbQuerySQL.AppendLine("  	T.PLANDATEEND, ");
            sbQuerySQL.AppendLine("  	T.PAYCITY, ");
            sbQuerySQL.AppendLine("  	T.PLANSTATE, ");
            sbQuerySQL.AppendLine("  	E.DICTMEMO, ");
            sbQuerySQL.AppendLine("  	T.MEMBERLEVEL, ");
            sbQuerySQL.AppendLine("  	T.OTHERMEMO, ");
            sbQuerySQL.AppendLine("  	A.BANKCODE, ");
            sbQuerySQL.AppendLine("  	B.DICTMEMO, ");
            sbQuerySQL.AppendLine("  	C.IMAGEENTITY, ");
            sbQuerySQL.AppendLine("  	C.SPECIALRELATENUMBER, ");
            sbQuerySQL.AppendLine("  	'消费' XFNAME, ");
            sbQuerySQL.AppendLine("  	IFNULL(XFSL, 0) XFSL, ");
            sbQuerySQL.AppendLine("  	ROUND(IFNULL(XFMONEYSUM, '0'), 2) XFMONEYSUM, ");
            sbQuerySQL.AppendLine("  	ROUND(IFNULL(XFREALSERVICEFEE, '0'),2) XFREALSERVICEFEE, ");
            sbQuerySQL.AppendLine("  	ROUND(IFNULL(XFEXTRASERVICEFEE, '0'),2) XFEXTRASERVICEFEE, ");
            sbQuerySQL.AppendLine("  	SFMINTIME, ");
            sbQuerySQL.AppendLine("  	'还款' HKNAME, ");
            sbQuerySQL.AppendLine("  	IFNULL(HKSL, 0) HKSL, ");
            sbQuerySQL.AppendLine("  	ROUND(IFNULL(HKMONEYSUM, '0'), 2) HKMONEYSUM, ");
            sbQuerySQL.AppendLine("  	ROUND(IFNULL(HKREALSERVICEFEE, '0'),2) HKREALSERVICEFEE, ");
            sbQuerySQL.AppendLine("  	ROUND(IFNULL(HKEXTRASERVICEFEE, '0'),2) HKEXTRASERVICEFEE, ");
            sbQuerySQL.AppendLine("  	HKMAXTIME, ");
            sbQuerySQL.AppendLine("  	ROUND(IFNULL(XFREALSERVICEFEE, '0')+IFNULL(XFEXTRASERVICEFEE, '0')+IFNULL(HKREALSERVICEFEE, '0')+IFNULL(HKEXTRASERVICEFEE, '0'),2) ZSFSUM ");
            sbQuerySQL.AppendLine("  FROM XYK_REPAYPLAN T ");
            sbQuerySQL.AppendLine("  LEFT JOIN XYK_BANKCARD A ON T.BANKCARDNO=A.CARDNO ");
            sbQuerySQL.AppendLine("  LEFT JOIN " + strDictSapace + ".DICT_XYK_BANKCODE B ON A.BANKCODE=B.DICTCODE ");
            sbQuerySQL.AppendLine("  LEFT JOIN " + strDictSapace + ".DICT_XYK_TRADESTATE E ON T.PLANSTATE=E.DICTCODE ");
            sbQuerySQL.AppendLine("  LEFT JOIN " + strDictSapace + ".DICT_XYK_PLANTYPE H ON T.PLANTYPE=H.DICTCODE ");
            sbQuerySQL.AppendLine("  LEFT JOIN MDA_PUBLICIMAGE C ON B.SYS_RECORDID=C.MAINTABLERECORDID ");
            sbQuerySQL.AppendLine("  AND B.DICTCODE=C.SPECIALRELATENUMBER ");
            sbQuerySQL.AppendLine("  LEFT JOIN " + strSysSapace + ".DB_TABLEDEFINE D ON C.MAINTABLEDEFINEID=D.TABLEID ");
            sbQuerySQL.AppendLine("  LEFT JOIN ( ");
            sbQuerySQL.AppendLine("  	SELECT ");
            sbQuerySQL.AppendLine("  		PLANID, ");
            sbQuerySQL.AppendLine("  		COUNT(*) XFSL, ");
            sbQuerySQL.AppendLine("  		SUM(MONEYSUM) XFMONEYSUM, ");
            sbQuerySQL.AppendLine("  		SUM(REALSERVICEFEE) XFREALSERVICEFEE, ");
            sbQuerySQL.AppendLine("  		SUM(EXTRASERVICEFEE) XFEXTRASERVICEFEE, ");
            sbQuerySQL.AppendLine("  		DATE_FORMAT(MIN(PLANTRADETIME),'%m.%d') SFMINTIME ");
            sbQuerySQL.AppendLine("  	FROM XYK_TRADEORDER M ");
            sbQuerySQL.AppendLine("  	WHERE " + clsSQLSyntax.IsNullSQL("Data", "M.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine("     AND ( M.TRADETYPE='POS01' OR M.TRADETYPE='ATM01' OR M.TRADETYPE='HBEI01' ) ");
            sbQuerySQL.AppendLine("  	GROUP BY PLANID ");
            sbQuerySQL.AppendLine("  ) F ON T.PLANID=F.PLANID ");
            sbQuerySQL.AppendLine("  LEFT JOIN ( ");
            sbQuerySQL.AppendLine("  	SELECT ");
            sbQuerySQL.AppendLine("  		PLANID, ");
            sbQuerySQL.AppendLine("  		COUNT(*) HKSL, ");
            sbQuerySQL.AppendLine("  		SUM(MONEYSUM) HKMONEYSUM, ");
            //sbQuerySQL.AppendLine("  		SUM(MONEYSUM-EXTRASERVICEFEE) HKMONEYSUM, /* 统计还款的时候需要扣除笔数费 */ ");
            sbQuerySQL.AppendLine("  		SUM(REALSERVICEFEE) HKREALSERVICEFEE, ");
            sbQuerySQL.AppendLine("  		SUM(EXTRASERVICEFEE) HKEXTRASERVICEFEE, ");
            sbQuerySQL.AppendLine("  		DATE_FORMAT(MAX(PLANTRADETIME),'%m.%d') HKMAXTIME ");
            sbQuerySQL.AppendLine("  	FROM XYK_TRADEORDER M ");
            sbQuerySQL.AppendLine("  	WHERE " + clsSQLSyntax.IsNullSQL("Data", "M.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine("     AND ( M.TRADETYPE='POS02' OR M.TRADETYPE='ATM02' OR M.TRADETYPE='HBEI02' ) ");
            sbQuerySQL.AppendLine("  	GROUP BY PLANID ");
            sbQuerySQL.AppendLine("  ) G ON T.PLANID=G.PLANID ");
            sbQuerySQL.AppendLine("  WHERE " + clsSQLSyntax.IsNullSQL("Data", "T.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine("  AND " + clsSQLSyntax.IsNullSQL("Data", "A.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine("  AND " + clsSQLSyntax.IsNullSQL("Data", "B.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine("  AND " + clsSQLSyntax.IsNullSQL("Data", "C.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine("  AND " + clsSQLSyntax.IsNullSQL("Data", "D.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine("  AND " + clsSQLSyntax.IsNullSQL("Data", "E.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine("  AND " + clsSQLSyntax.IsNullSQL("Data", "H.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine("  AND T.UNITCODE='" + strUnitCode + "' ");
            sbQuerySQL.AppendLine("  AND T.PERSONCODE='" + strPersonCode + "' ");
            sbQuerySQL.AppendLine("  AND " + strSQLCondition + " /*计划详情中加，还款计划中不需要加*/ ");
            sbQuerySQL.AppendLine("  AND UPPER(D.TABLENAME)='DICT_XYK_BANKCODE' /*查询今年的*/ ");
            sbQuerySQL.AppendLine("  AND T.PLANTIME >= CONCAT(DATE_FORMAT(NOW(), '%Y'),'-01-01 00:00:00') ");
            sbQuerySQL.AppendLine("  AND T.PLANTIME <= CONCAT(DATE_FORMAT(NOW(), '%Y'),'-12-31 23:59:59') /*查询今年的*/ ");
            sbQuerySQL.AppendLine("  ORDER BY T.PLANTIME DESC ");

            #endregion

            //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "pz_clsCrCardData_GetOlapRepayPlanResult.txt", sbQuerySQL.ToString(), false);

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            strRtData = myDB.YookingExecuteJson("Data", sbQuerySQL.ToString());

            return strRtData; //数据库查询结果
        }

        //注释：王庆文 2020年03月19日=========================================================
        //根据还款计划ID，查询子表XYK_TradeOrder，获取刷卡、还款的详细消费记录清单
        // POS01=信用卡刷卡、POS02=信用卡还款、ATM01=信用卡套刷、ATM02=信用卡套入、
        //HBEI01=花呗消费、HBEI02=花呗还款、BKGE01=佣金提现、HYCZ01=会员充值
        public string LoadRepayTradeOrderList(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strPlanID = "CHN0000"; //还款计划ID

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 1)
            {
                strPlanID = strArray[0];
            }

            #endregion

            #region 生成查询记录的SQL语句

            clsDBSpace mySpace = new clsDBSpace(); //表空间名
            string strDictSapace = mySpace.GetDBSpaceName("Dict");

            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine(" SELECT ");
            sbQuerySQL.AppendLine(" 	T.REALTRADESTATE, ");
            sbQuerySQL.AppendLine(" 	B.DICTMEMO REALTRADESTATENAME, ");
            sbQuerySQL.AppendLine(" 	T.TRADETYPE, ");
            sbQuerySQL.AppendLine(" 	A.DICTMEMO TRADETYPENAME, ");
            sbQuerySQL.AppendLine(" 	T.PLANTRADETIME, ");
            sbQuerySQL.AppendLine(" 	T.MONEYSUM, ");
            //sbQuerySQL.AppendLine(" 	IF((T.TRADETYPE='POS02' OR T.TRADETYPE='HBEI02'),ROUND((T.MONEYSUM-T.EXTRASERVICEFEE), 2),ROUND(T.MONEYSUM, 2)) MONEYSUM, ");
            sbQuerySQL.AppendLine(" 	T.REALSERVICEFEE, ");
            sbQuerySQL.AppendLine(" 	T.EXTRASERVICEFEE ");
            sbQuerySQL.AppendLine(" FROM XYK_TRADEORDER T ");
            sbQuerySQL.AppendLine(" LEFT JOIN " + strDictSapace + ".DICT_XYK_TRADETYPE A ON T.TRADETYPE = A.DICTCODE ");
            sbQuerySQL.AppendLine(" LEFT JOIN " + strDictSapace + ".DICT_XYK_TRADESTATE B ON T.REALTRADESTATE = B.DICTCODE ");
            sbQuerySQL.AppendLine(" WHERE " + clsSQLSyntax.IsNullSQL("Data", "T.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" AND " + clsSQLSyntax.IsNullSQL("Data", "A.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" AND " + clsSQLSyntax.IsNullSQL("Data", "B.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" AND T.PLANID = '" + strPlanID + "' ");
            sbQuerySQL.AppendLine("/* AND (T.TRADETYPE = 'POS01' OR T.TRADETYPE = 'POS02') */");
            sbQuerySQL.AppendLine(" ORDER BY T.PLANTRADETIME ASC ");

            #endregion

            //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "wqw_clsCrCardData_LoadRepayTradeOrderList.txt", sbQuerySQL.ToString(), false);

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            strRtData = myDB.YookingExecuteJson("Data", sbQuerySQL.ToString());

            return strRtData; //数据库查询结果
        }

        //注释：王庆文 2020年03月19日===================================================
        //根据自定义的条件，查询符合条件的还款计划信息
        public string LoadReplayPlanInfo(string strB64RequestData)
        {
            string strRtData = "no data";

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strUnitCode = "CHN0000"; //平台编码
            string strPersonCode = "00000"; //人员编码
            string strSQLCondition = "1=1"; //附加查询条件

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 3)
            {
                strUnitCode = strArray[0];
                strPersonCode = strArray[1];
                strSQLCondition = strArray[2];
            }

            #endregion

            #region 生成查询记录的SQL语句

            clsDBSpace mySpace = new clsDBSpace(); //表空间名
            string strDictSapace = mySpace.GetDBSpaceName("Dict");

            StringBuilder sbQuerySQL = new StringBuilder();
            sbQuerySQL.AppendLine(" SELECT ");
            sbQuerySQL.AppendLine(" 	T.UNITCODE, ");
            sbQuerySQL.AppendLine(" 	T.PERSONCODE, ");
            sbQuerySQL.AppendLine(" 	T.PLANID, ");
            sbQuerySQL.AppendLine(" 	T.PLANTYPE AS PLANTYPECODE, ");
            sbQuerySQL.AppendLine(" 	A.DICTMEMO AS PLANTYPEMEMO, ");
            sbQuerySQL.AppendLine(" 	T.PLANTIME, ");
            sbQuerySQL.AppendLine(" 	T.BANKCARDNO, ");
            sbQuerySQL.AppendLine(" 	T.PLANAMOUNT, ");
            sbQuerySQL.AppendLine(" 	T.CARDBALANCE, ");
            sbQuerySQL.AppendLine(" 	T.PLANDATEBEGIN, ");
            sbQuerySQL.AppendLine(" 	T.PLANDATEEND, ");
            sbQuerySQL.AppendLine(" 	T.PAYCITY AS PAYCITYCODE, ");
            sbQuerySQL.AppendLine(" 	B.DICTMEMO AS PAYCITYNAME, ");
            sbQuerySQL.AppendLine(" 	T.PLANSTATE AS PLANSTATECODE, ");
            sbQuerySQL.AppendLine(" 	C.DICTMEMO AS PLANSTATENAME, ");
            sbQuerySQL.AppendLine(" 	T.MEMBERLEVEL AS MEMBERLEVELCODE, ");
            sbQuerySQL.AppendLine(" 	D.LEVELMEMO AS MEMBERLEVELNAME, ");
            sbQuerySQL.AppendLine(" 	T.OTHERMEMO, ");
            sbQuerySQL.AppendLine(" 	T.SYS_RECORDID ");
            sbQuerySQL.AppendLine(" FROM XYK_REPAYPLAN T ");
            sbQuerySQL.AppendLine(" LEFT JOIN " + strDictSapace + ".DICT_XYK_PLANTYPE A ON A.DICTCODE = T.PLANTYPE ");
            sbQuerySQL.AppendLine(" LEFT JOIN " + strDictSapace + ".DICT_XZQH_2018 B ON (B.DICTCODE = T.PAYCITY OR B.DICTCODE=SUBSTRING(T.PAYCITY,15,6)) ");
            sbQuerySQL.AppendLine(" LEFT JOIN " + strDictSapace + ".DICT_XYK_TRADESTATE C ON C.DICTCODE = T.PLANSTATE ");
            sbQuerySQL.AppendLine(" LEFT JOIN XYK_MEMBER_LEVEL D ON D.LEVELCODE = T.MEMBERLEVEL ");
            sbQuerySQL.AppendLine(" WHERE " + clsSQLSyntax.IsNullSQL("Data", "T.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" AND " + clsSQLSyntax.IsNullSQL("Data", "D.SYS_CANCELDATETIME"));
            sbQuerySQL.AppendLine(" AND T.UNITCODE = '" + strUnitCode + "' ");
            sbQuerySQL.AppendLine(" AND T.PERSONCODE = '" + strPersonCode + "' ");
            sbQuerySQL.AppendLine(" AND " + strSQLCondition);

            #endregion

            //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "wqw_clsCrCardData_LoadReplayPlanInfo.txt", sbQuerySQL.ToString());

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            strRtData = myDB.YookingExecuteJson("Data", sbQuerySQL.ToString());

            return strRtData; //数据库查询结果
        }

        //注释：王庆文 2020年04月15日=====================================================
        //根据计划ID，删除该计划所属的全部交易订单数据
        public string DeleteTradeOrderList(string strB64RequestData)
        {
            object objResult = 0; //受影响的行数

            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strPlanID = "000000"; //交易计划的PlanID
            string strUserName = "test"; //当前操作用户名

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 2)
            {
                strPlanID = strArray[0];
                strUserName = strArray[1];
            }

            #endregion

            #region 删除交易订单的SQL语句

            string strCurTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            StringBuilder sbDelSQL = new StringBuilder();
            sbDelSQL.AppendLine(" update XYK_TradeOrder set ");
            sbDelSQL.AppendLine("    SYS_CANCELUSERNAME='" + strUserName + "', ");
            sbDelSQL.AppendLine("    SYS_CANCELDATETIME='" + strCurTime + "', ");
            sbDelSQL.AppendLine("    SYS_CANCELREASON='用户在APP端主动删除' ");
            sbDelSQL.AppendLine(" where PlanID='" + strPlanID + "' ");

            #endregion

            //clsRWFile myLog = new clsRWFile(); //将待执行的SQL语句记录下来
            //myLog.WriteInfoToTxtFile("SysLog", "wqw.txt", sbQuerySQL.ToString());

            clsDbSQLLogic myDB = new clsDbSQLLogic(); //实例化数据库操作类
            objResult = myDB.YookingExecuteNonQuery("Data", sbDelSQL.ToString());

            return objResult.ToString(); //返回数据库操作的结果
        }

        //注释：王庆文 2020年04月17日======================================================
        //会员第一次绑卡成功之后，需要给自己的上级会员进行绑卡奖励，
        //上级会员的级别不同，奖励的金额也各不相同。绑卡奖励只能一人一次。
        public string PayBindCardReward(string strB64RequestData)
        {
            //先进行解密，然后在进行中文解码，最后得到明文的请求数据
            string strRequestData = clsHandleData.DeUrlRequest(strB64RequestData);

            #region 将strRequestData包含的各种参数一一解析出来

            string strUnitCode = "CHN0000"; //平台编码
            string strMID = "000000000000"; //会员编码

            //这些参数用★分隔开，客户端与服务器端要一致
            string[] strArray = strRequestData.Split('★');
            if (strArray.Length >= 2)
            {
                strUnitCode = strArray[0];
                strMID = strArray[1];
            }

            #endregion

            //自己的上级会员得到绑卡奖励
            clsMbrReward myPay = new clsMbrReward(); 
            myPay.CommitBindCardRewardData(strUnitCode, strMID);

            return "{\"result\":\"Update Member Level Complete!\"}";
        }


    }
}
